package com.txazo.bean;

import javax.ejb.EJB;
import javax.faces.context.FacesContext;

import com.txazo.domain.User;
import com.txazo.service.UserService;

/**
 * 用户注册Bean
 * 
 * @author txazo
 * @since 1.0
 * 
 */
public class RegisterBean {

	@EJB(beanName = "userService")
	private UserService userService;

	private String username;
	private String password;

	public String register() {
		User user = new User(username, password);
		User register = userService.register(user);
		if (register != null) {
			FacesContext.getCurrentInstance().getExternalContext()
					.getSessionMap().put("user", register);
			return "success";
		}
		return "input";
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

}
